﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class HoTroKiThuat : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnYeuCau_Click(object sender, ImageClickEventArgs e)
    {
        System.Net.Mail.MailMessage objEmail = new System.Net.Mail.MailMessage();
        System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress(txtEmail.Text, txtYourName.Text);
        objEmail.From = fromAddress;
        objEmail.To.Add("haipt78@gmail.com");
        objEmail.Subject = txtSubject.Text;
        objEmail.Body = txtNoiDung.Text;
        objEmail.IsBodyHtml = true;

        try
        {
            System.Net.Mail.SmtpClient mailclient = new System.Net.Mail.SmtpClient();
            System.Net.NetworkCredential auth = new System.Net.NetworkCredential("haipy78@gmail.com", "0838497929");
            mailclient.Host = "smtp.gmail.com";
            mailclient.EnableSsl = true;
            mailclient.UseDefaultCredentials = true;
            mailclient.Credentials = auth;
            mailclient.Send(objEmail);
            Response.Redirect("GuiMailThanhCong.aspx");
        }

        catch (Exception ex)
        {
            //Console.WriteLine("Exception is:" + ex.ToString());
            throw ex; //or return the error by some other means, say on a label
        }
    }
}
